<?php 
require('Common/ConnDB.php');
require('Model.php');
class geshouModel extends Model
{ 
  public function __construct()
  {
    parent::__construct();

  }
  public function getgeshouList()
  {
    $sql="select * from geshous";
    $data=$this->conn->query($sql);
    return $data;
  }
  //将用户信息写入数据库
  public function addgeshouInfo()
  { //获取用户提交的内容
    $geshouname = trim($_POST['geshouname']);
       $uploaddate =$_POST['uploaddate'];
   $tid =$_POST['tid'];
   $intro =$_POST['intro'];
          $pic=$this->uploadfile("pic",'vimages/');
          $sql="insert into geshous values('null','$geshouname','$tid','$pic','$intro','$uploaddate','null','null','null','null')";
      $result=$this->conn->query($sql);//往数据库写入信息
      return $result;
     
  
    }
          //更新用户，获取用户信息
        public function getgeshoubyID()
        {
          $vid=$_GET['vid'];
          $sql="select *from geshous where vid=$vid";
          $data=$this->conn->query($sql);
            return $data;
        }
         public function updategeshouInfo(){
      //上传头像文件  
     $pic=$this->uploadfile("pic",'vimages/');
     //1.获取修改用户提交的内容
     $vid=$_POST['vid'];
  $geshouname=$_POST['geshouname'];
   $uploaddate =$_POST['uploaddate'];
   $tid =$_POST['tid'];
   $intro =$_POST['intro'];
  if($_FILSES['pic']['filename']=='')
  {

   $sql="update geshous set geshouname='{$geshouname}',uploaddate='{$uploaddate}',tid='{$tid}',intro='{$intro}',pic='{$pic}' where vid=$vid";
  }
  else
  {

   $sql="update geshous set geshouname='{$geshouname}',uploaddate='{$uploaddate}',tid='{$tid}',intro='{$intro}',pic='{$pic}' where vid=$vid";
     }
   $result=$this->conn->query($sql);//写入数据库
   return $result;
    }
     public function delgeshoubyID()
     {
        $vid=$_GET['vid'];
          $sql="delete from geshous where vid=$vid";
          $data=$this->conn->query($sql);
            return $data;
     }

}

 ?>
